package com.example.demo;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class AsyncServiceImpl implements AsyncService {
	
	@PersistenceContext
	EntityManager em;
	
	
	@Async
	public void task1() {
		
		System.out.println(Thread.currentThread().getName());
		
		Query query = em.createNativeQuery("select * from user");
		
//		query.unwrap(User.class);
		
		List list = query.getResultList();
		
		System.out.println(list);
		
	}

}
